<?php include_once '../../../include/inc_session.php';	

	$idContrat = isset($_POST['Identifiant_contrat'])? $_POST['Identifiant_contrat']: $_GET['idcontrat'];
	$idRib = isset($_POST['idrib'])? $_POST['idrib'] : $_GET['idrib'];
	$idSouscripteur = isset($_POST['idpers'])? $_POST['idpers'] : $_GET['idpers'];
	
	$oContrat = new dataObject_contrat($idContrat);

	$oRib = new dataObject_rib($idRib);
	
	
	$BANQUE  =  (isset($_POST['OCB_Code_banque_rib']))  ?  $_POST['OCB_Code_banque_rib']  : $oRib->_CODE_BANQUE_RIB;
	$GUICHET =  (isset($_POST['OCG_Code_guichet_rib'])) ?  $_POST['OCG_Code_guichet_rib'] : $oRib->_CODE_GUICHET_RIB;
	$COMPTE  =  (isset($_POST['ONM_Numero_compte_rib']))  ?  $_POST['ONM_Numero_compte_rib']  : $oRib->_NUMERO_COMPTE_RIB;
	$CLE     =  (isset($_POST['OCR_Cle_rib']))  ?  $_POST['OCR_Cle_rib']  : $oRib->_CLE_RIB;
	
	$nom_module_saisie = "Détail RIB";

	if ($gbFormValid) 
	{
		$oRib->_CODE_BANQUE_RIB 		= $BANQUE;
		$oRib->_CODE_GUICHET_RIB 		= $GUICHET;
		$oRib->_NUMERO_COMPTE_RIB 		= $COMPTE;
		$oRib->_CLE_RIB 				= $CLE;
		$oRib->_ETAT_RIB 				= 'A';
		$oRib->_IDENTIFIANT_PERSONNE  	= $idSouscripteur;
		
		if($idRib != '')
		{			
			$id = $oRib->rib_update();
			if($id === false) $oForm->ajouterErreur(chgmt_couv_mod_rib_pbm);
			else $oForm->ajouterErreur(rib_modif);
		}
		else
		{
			$id = $oRib->rib_insert();
			if(!$id) $oForm->ajouterErreur(chgmt_couv_crea_rib_pbm);
			else $oForm->ajouterErreur(rib_creation);
		}
		
	}
	if( isset($_GET['supp']))
	{
		$oRib->_ETAT_RIB 	= 'I';
		$del = $oRib->rib_update();
		
		if($del===false) $msg = "&msg=pbm_del"; 
		else $msg = "&msg=del"; 
		header("location:index.php?idcontrat=".$idContrat."&idpers=".$idSouscripteur.$msg); 
		
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RIB</title>
			<link rel="stylesheet" type="text/css" href="../../../css/main.css" />
            <link rel="stylesheet" type="text/css" href="list.css" />
			<!--[if IE 7]>
            	<link rel="stylesheet" type="text/css" href="../../../css/ie7.css" />
            	<link rel="stylesheet" type="text/css" href="form_ie7.css" />
            <![endif]--></head>

<body>
<div id="sf_menu1">
<h3><?php echo $oBloc->_MENU_NOM ?></h3>
	<div id="information_erreur" class="false">
        <ul id="message">
        	<li><?php $aMsg =$oForm->getValidMessage(); echo (!empty($aMsg))? $aMsg[0]['message'] : ''; ?></li>
        </ul>
    </div>
</div>
<div class="cleared"></div>

<div class="corps1">
<div class="cleared"></div>
<div id="br"></div>

<form action="<?php echo $sEditFormAction; ?>" method="post" name="form1" id="form1"><div class="imgleft"></div>
	<div class="imgmiddle">
    <div class="btn">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $oFonction->_MENU_AFFICHE; ?></h5>
        </span><span class="btnright"></span>
    </div>
  	<div class="btn1">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $nom_module_saisie; ?></h5>
        </span>
        <span class="btnright"></span>
    </div>
	<div class="formulaire">
  <table class="tabform">
    <tr >
      <td  class="td1">CODE BANQUE</td>   
      <td><input name="OCB_Code_banque_rib" id="OCB_Code_banque_rib" type="text" value="<?php echo $BANQUE; ?>" maxlength="5" /></td>
    </tr>
    <tr >
      <td class="td1">CODE GUICHET</td>
      <td><input name="OCG_Code_guichet_rib" id="OCG_Code_guichet_rib" type="text" value="<?php echo $GUICHET; ?>" size="20" maxlength="5" /></td>
    </tr>
    <tr >
      <td class="td1">NUMERO DE COMPTE</td>
      <td><input name="ONM_Numero_compte_rib" id="ONM_Numero_compte_rib" type="text" value="<?php echo $COMPTE; ?>" size="20" maxlength="11" /></td>
    </tr>
    <tr >
      <td class="td1">CLE RIB</td>
      <td><input name="OCR_Cle_rib" id="OCR_Cle_rib" type="text" value="<?php echo $CLE; ?>" size="20" maxlength="2" /></td>
       </tr>
  </table>

       </div>
    
 </div>

<div class="imgright"></div>				
<div class="cleared"></div>
    
    
    <div class="bt1"> <a href="index.php?idcontrat=<?php echo $idContrat;?>&idpers=<?php echo $idSouscripteur;?>"><span class="btleft"></span>
        <span class="btmiddle">Annuler</span>
        <span class="btright"></span>
    </a></div>
    
      <div class="bt">
	<span class="btleft"></span><input type="submit" value="Valider" class="resizeall btmiddle"/>
    <span class="btright"></span></div>
    
	 
  
       <div class="cleared"></div>


  <input type="hidden" name="Identifiant_rib" value="<?php echo $idRib;?>" />
  <input type="hidden" name="Etat_rib" value="" />
  <input type="hidden" name="idpers" value="<?php echo $idSouscripteur;?>" />
  <input type="hidden" name="MM_insert" value="form1" />
</form>
</div>
</body>
</html>
<?php
include_once PATH_INCLUDE.'inc_pied_page.php';

?>